package a.j;

import a.c.e;
import a.c.j;
import a.c.k;

import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.geom.AffineTransform;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.EventObject;

public class nf
  extends gf
{
  private final k m;
  private final j G;
  private hd H;
  private ld I;
  private JComponent J;
  private final CellEditorListener K = new b_();
  private hf L;
  private xc M;
  private PropertyChangeListener N;
  public static int O;
  
  public nf(hd paramhd, j paramj)
  {
    this(q.a(paramhd), paramj);
  }
  
  public nf(k paramk, j paramj)
  {
    this.m = paramk;
    this.G = paramj;
  }
  
  public boolean editNode(e parame, EventObject paramEventObject)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (a(parame))
      {
        if (bool) {
          break label45;
        }
        if (!v()) {
          break label44;
        }
        if (bool) {
          break label45;
        }
        if (z()) {
          break label44;
        }
      }
    }
    return false;
    label44:
    label45:
    ld localld = k().w(parame);
    hd localhd = c(parame);
    if (localhd != null) {
      if (!bool)
      {
        if (paramEventObject != null)
        {
          if (bool) {
            break label165;
          }
          if (!localhd.isCellEditable(paramEventObject)) {}
        }
        else
        {
          a(localld, localhd);
        }
      }
      else
      {
        if (!bool) {
          if ((paramEventObject instanceof MouseEvent))
          {
            if (bool) {
              break label163;
            }
            if ((((MouseEvent)paramEventObject).getID() == 500) && ((bool) || (this.L != null)))
            {
              if (bool) {
                break label163;
              }
              if (v()) {
                this.L.mouseClicked((MouseEvent)paramEventObject);
              }
            }
          }
        }
        label163:
        return true;
      }
    }
    label165:
    return false;
  }
  
  public boolean a(e parame)
  {
    return c(parame) != null;
  }
  
  private void c(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    sc localsc;
    if (!bool) {
      if (!v())
      {
        if ((!bool) && (!d(paramMouseEvent))) {
          return;
        }
        localsc = a(paramMouseEvent);
        if (!bool)
        {
          if (localsc.m() == null) {
            return;
          }
          editNode(localsc.m(), paramMouseEvent);
        }
        if (!bool) {
          if (!ld.D) {
            return;
          }
        }
      }
      else
      {
        a(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
      }
    }
    if (((bool) || (v())) && (paramMouseEvent.getID() == 501))
    {
      localsc = a(paramMouseEvent);
      e locale = localsc.m();
      if (((!bool) && (locale == null)) || ((locale != this.I.n()) && ((bool) || (!z())))) {
        y();
      }
    }
  }
  
  public Object b(e parame)
  {
    return this.G.get(this.I.n());
  }
  
  public void a(e parame, Object paramObject)
  {
    this.G.a(parame, paramObject);
  }
  
  protected boolean d(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (!bool)
    {
      if (paramMouseEvent.getID() != 500) {
        break label34;
      }
      if (bool) {
        break label31;
      }
    }
    label31:
    label34:
    return paramMouseEvent.getClickCount() == 2;
  }
  
  public hd c(e parame)
  {
    boolean bool = ld.E;
    if (!bool) {}
    Object localObject = this.m != null ? this.m.get(parame) : null;
    return (bool) || ((localObject instanceof hd)) ? (hd)localObject : null;
  }
  
  public boolean v()
  {
    return this.H != null;
  }
  
  public void a(ld paramld, hd paramhd)
  {
    boolean bool = ld.E;
    if (!bool)
    {
      if (v())
      {
        if (bool) {
          break label38;
        }
        if (!z()) {
          y();
        }
      }
      if (bool) {
        break label62;
      }
    }
    if (!v())
    {
      label38:
      this.H = paramhd;
      this.I = paramld;
      paramhd.addCellEditorListener(this.K);
      label62:
      a(paramhd.getNodeCellEditorComponent(this.i, paramld, b(paramld.n()), paramld.H()), paramld);
    }
  }
  
  public hd w()
  {
    return this.H;
  }
  
  public e x()
  {
    return (ld.E) || (this.I != null) ? this.I.n() : null;
  }
  
  public void y()
  {
    if ((ld.E) || (this.H != null)) {
      this.H.cancelCellEditing();
    }
  }
  
  public boolean z()
  {
    if ((ld.E) || (this.H != null)) {
      return this.H.stopCellEditing();
    }
    return true;
  }
  
  protected void A()
  {
    if ((ld.E) || (this.H != null))
    {
      this.H.removeCellEditorListener(this.K);
      C();
      this.H = null;
      g();
    }
  }
  
  protected void B()
  {
    if (!ld.E)
    {
      if (this.H != null) {
        a(this.I.n(), this.H.getCellEditorValue());
      }
    }
    else
    {
      this.H.removeCellEditorListener(this.K);
      C();
      this.H = null;
      g();
    }
  }
  
  public void mouseMoved(MouseEvent paramMouseEvent)
  {
    if ((ld.E) || (this.L != null)) {
      this.L.mouseMoved(paramMouseEvent);
    }
  }
  
  private void e(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (paramMouseEvent.getID() == 501)
    {
      e locale = a(paramMouseEvent).m();
      if (((!bool) && (locale == null)) || ((locale != this.I.n()) && ((bool) || (!z())))) {
        y();
      }
    }
  }
  
  public void mouseReleased(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.L != null)
      {
        this.L.mouseReleased(paramMouseEvent);
        if (bool) {
          break label40;
        }
        e(paramMouseEvent);
        if (!ld.D) {
          return;
        }
      }
    }
    label40:
    c(paramMouseEvent);
  }
  
  public void mouseDragged(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.L != null)
      {
        this.L.mouseDragged(paramMouseEvent);
        if (bool) {
          break label40;
        }
        e(paramMouseEvent);
        if (!ld.D) {
          return;
        }
      }
    }
    label40:
    c(paramMouseEvent);
  }
  
  public void mousePressed(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.L != null)
      {
        this.L.mousePressed(paramMouseEvent);
        if (bool) {
          break label40;
        }
        e(paramMouseEvent);
        if (!ld.D) {
          return;
        }
      }
    }
    label40:
    c(paramMouseEvent);
  }
  
  public void mouseClicked(MouseEvent paramMouseEvent)
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.L != null)
      {
        this.L.mouseClicked(paramMouseEvent);
        if (bool) {
          break label40;
        }
        e(paramMouseEvent);
        if (!ld.D) {
          return;
        }
      }
    }
    label40:
    c(paramMouseEvent);
  }
  
  protected void a(JComponent paramJComponent, ld paramld)
  {
    if (!ld.E) {
      if (paramJComponent.getNextFocusableComponent() == null) {
        paramJComponent.setNextFocusableComponent(this.i.B());
      }
    }
    this.i.T().add(paramJComponent);
    this.J = paramJComponent;
    hf localhf = new hf();
    a(localhf, null, null, null);
    this.L = localhf;
    AffineTransform localAffineTransform = AffineTransform.getTranslateInstance(paramld.a(), paramld.b());
    localhf.a(paramJComponent, localAffineTransform);
    this.M = new xc(this.i, paramJComponent, localAffineTransform);
    this.i.a(this.M);
    paramJComponent.setBounds(0, 0, (int)paramld.c(), (int)paramld.d());
    paramJComponent.validate();
    paramJComponent.requestFocusInWindow();
    paramJComponent.repaint();
    if (this.N == null)
    {
      KeyboardFocusManager localKeyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
      this.N = new a_(localKeyboardFocusManager);
      localKeyboardFocusManager.addPropertyChangeListener("permanentFocusOwner", this.N);
    }
  }
  
  protected void C()
  {
    boolean bool = ld.E;
    if (!bool) {
      if (this.N != null)
      {
        KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener("permanentFocusOwner", this.N);
        this.N = null;
      }
    }
    if (!bool) {
      if (this.J != null)
      {
        this.L.g();
        this.i.T().remove(this.J);
        this.i.b(this.M);
        this.i.B().repaint();
        this.L = null;
      }
    }
    this.J = null;
  }
  
  private void a(Component paramComponent)
  {
    boolean bool2 = ld.E;
    boolean bool1 = ld.D;
    if (!v()) {
      return;
    }
    Object localObject = paramComponent;
    if (localObject != null) {
      if (!bool2) {
        if (localObject == this.i.T()) {
          return;
        }
      }
    }
    label107:
    label108:
    label111:
    while (bool2)
    {
      if (!bool2) {
        if (!(localObject instanceof Window))
        {
          if (bool2) {
            break label108;
          }
          if (!(localObject instanceof Applet)) {
            break label107;
          }
          if (bool2) {
            break label111;
          }
          if (((Component)localObject).getParent() != null) {
            break label107;
          }
        }
      }
      if (localObject == SwingUtilities.getRoot(this.i)) {
        if (!bool2)
        {
          if (!z()) {
            y();
          }
        }
        else if (bool1)
        {
          localObject = ((Component)localObject).getParent();
          if (!bool1) {
            break;
          }
        }
      }
    }
  }
  
  class a_
    implements PropertyChangeListener
  {
    private final KeyboardFocusManager a;
    
    public a_(KeyboardFocusManager paramKeyboardFocusManager)
    {
      this.a = paramKeyboardFocusManager;
    }
    
    public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
    {
      nf.this.a(this.a.getPermanentFocusOwner());
    }
  }
  
  final class b_
    implements CellEditorListener
  {
    b_() {}
    
    public void editingStopped(ChangeEvent paramChangeEvent)
    {
      nf.this.B();
    }
    
    public void editingCanceled(ChangeEvent paramChangeEvent)
    {
      nf.this.A();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     a.j.nf

 * JD-Core Version:    0.7.0.1

 */